<template>
  <div>
    <Form label-position="right" :label-width="400" :model="checkItem">
      <Row class="mb20">
        <Col span="5" class="ivu-form-item-label">登记证编号：</Col>
        <Col span="6" class="ivu-form-item-content">
          <Input v-model="checkItem.acc0m1" placeholder="请输入登记证编号"></Input>
        </Col>
        <Col span="5" class="ivu-form-item-label">审验日期：</Col>

<!--        <DatePicker v-model="time" type="date" format="yyyy-MM-dd" placeholder="请选择" style="width: 215px" @on-change="changeDate"></DatePicker>-->
        <Col span="6" class="ivu-form-item-content">
          <Input v-model="time" v-if="time === ''" placeholder="请点击获取当前日期" @on-focus="saveTime"></Input>
          <Input v-model="time" v-else readonly placeholder="请点击获取当前日期" @on-focus="saveTime"></Input>
        </Col>
      </Row>
      <Row class="mb20">
        <Col span="5" class="ivu-form-item-label">审验情况记载：</Col>
        <Col span="6" class="ivu-form-item-content">
          <Input v-model="checkItem.aac18a" placeholder="请输入审验情况记载"></Input>
        </Col>
        <Col span="5" class="ivu-form-item-label">审验年度：</Col>
        <Col span="6" class="ivu-form-item-content">
          <Input v-model="year" v-if="year === ''" placeholder="请点击获取当前年度" @on-focus="saveYear"></Input>
          <Input v-model="year" v-else readonly placeholder="请点击获取当前年度" @on-focus="saveYear"></Input>
<!--          <DatePicker v-model="year"  type="year" placeholder="请选择" style="width: 215px" @on-change="changeYear"></DatePicker>-->
        </Col>
      </Row>
      <Row class="mb20">
        <Col span="5" class="ivu-form-item-label">审验人：</Col>
        <Col span="6" class="ivu-form-item-content">
          <Input v-model="checkItem.aac18c" placeholder="请输入审验人"></Input>
        </Col>
        <Col span="5" class="ivu-form-item-label">审验机构：</Col>
        <Col span="6" class="ivu-form-item-content">
          <Input v-model="checkItem.aac18b" placeholder="审验机构"></Input>
        </Col>
      </Row>
      <Row class="mb20">
        <Col span="5" class="ivu-form-item-label">备注：</Col>
        <Col span="6" class="ivu-form-item-content">
          <Input v-model="checkItem.aae013" type="textarea" :autosize="{maxRows: 7,minRows: 1}" placeholder="请输入备注"></Input>
        </Col>
      </Row>
    </Form>
  </div>
</template>

<script>
import { date2str } from '@/api/eventlist'
export default {
  props: {
    unemploymentItem1: Object
  },
  name: 'index.vue',
  data () {
    return {
      time: '',
      year: '',
      checkItem: {
        apiName: 'sq4jycyznj',
        acc0m1: '',
        aac182: '',
        aae001: '',
        aac18a: '',
        aac18b: '',
        aac18c: '',
        aae013: ''
      }
    }
  },
  watch: {
    // 回显
    unemploymentItem1 (a) {
      this.checkItem = a
      this.time = this.checkItem.aac182
      this.year = this.checkItem.aae001
      console.log(a, '555555555555555555')
    }
  },
  methods: {
    checkData () {
      if (this.checkItem.acc0m1 === '' || this.checkItem.acc0m1 === undefined || this.checkItem.acc0m1 === null) {
        this.$Notice.error({ title: '请输入登记证编号', desc: '' })
        return false
      }
      if (this.checkItem.aac18a === '' || this.checkItem.aac18a === undefined || this.checkItem.aac18a === null) {
        this.$Notice.error({ title: '请输入审验情况记载', desc: '' })
        return false
      }
      if (this.checkItem.aac182 === '' || this.checkItem.aac182 === undefined || this.checkItem.aac182 === null) {
        this.$Notice.error({ title: '请选择审验日期', desc: '' })
        return false
      }
      if (this.checkItem.aae001 === '' || this.checkItem.aae001 === undefined || this.checkItem.aae001 === null) {
        this.$Notice.error({ title: '请选择审验年度', desc: '' })
        return false
      }
      if (this.checkItem.aac18b === '' || this.checkItem.aac18b === undefined || this.checkItem.aac18b === null) {
        this.$Notice.error({ title: '请输入审验机构', desc: '' })
        return false
      } if (this.checkItem.aac18c === '' || this.checkItem.aac18c === undefined || this.checkItem.aac18c === null) {
        this.$Notice.error({ title: '请输入审验人', desc: '' })
        return false
      } if (this.checkItem.aae013 === '' || this.checkItem.aae013 === undefined || this.checkItem.aae013 === null) {
        this.$Notice.error({ title: '请输入备注', desc: '' })
        return false
      }
      this.$emit('checkItem', this.checkItem)
    },
    saveTime () {
      let data = new Date()
      this.time = date2str(data)
      this.checkItem.aac182 = this.time
    },
    saveYear () {
      let data = new Date()
      this.year = date2str(data).substr(0, 4)
      this.checkItem.aae001 = date2str(this.year).toString().substr(0, 4)
    }

  }
}
</script>

<style scoped>
  .ivu-row{
    margin-bottom: 15px;
  }
</style>
